package com.offer;

import java.util.HashSet;
import java.util.Set;

/**
 * @Author: huangzhigao
 * @Date: 2023/3/5 19:32
 */
public class offer61 {
    public boolean isStraight(int[] nums) {
        Set<Integer> set = new HashSet<>();
        int min = Integer.MAX_VALUE;
        int max = Integer.MIN_VALUE;
        for (int num : nums) {
            if (num == 0) {
                continue;
            }
            if (set.contains(num)) {
                return false;
            }
            set.add(num);
            min = Math.min(num, min);
            max = Math.max(num, max);
        }
        return max - min <= 4;
    }
}
